
#ifndef __C_GUI_ICON_INCLUDED__
#define __C_GUI_ICON_INCLUDED__

#include "irrTypes.h"
#include "IGUIElement.h"
#include "EGUIIconFactoryEnums.h"

namespace irr 
{
namespace video
{
	class ITexture;
}

namespace gui 
{

class IGUISpriteBank;
class IGUIFont;
class IGUIEditBox;
class IGUIStaticText;

class CGUIIcon : public IGUIElement
{
public:
	//! Constructor
	CGUIIcon(IGUIEnvironment *env, IGUIElement *parent, s32 id, core::position2d<s32> pos, 
		IGUISpriteBank *sprites, wchar_t *caption=0);

	//! Destructor
	virtual ~CGUIIcon();

	// standard GUI functions
	virtual bool OnEvent(SEvent event);
	virtual void draw();
	virtual void setEnabled(bool enabled);
	virtual void setText(const wchar_t *text);
	virtual const wchar_t* getText();
	virtual bool isPointInside(const core::position2d<s32>& point) const;

	// get/set functions

	void setLayout(EGUI_ICON_LAYOUT layout);
	EGUI_ICON_LAYOUT getLayout();
	void setSelected(bool selected);
	bool getSelected();
	void setAnimated(bool animate);
	bool getAnimated();
	void setEditable(bool editable);
	bool getEditable();
	void setSpriteBank(IGUISpriteBank *sprites);
	IGUISpriteBank* getSpriteBank();
	void setSprites(s32 normal, s32 pressed=-1);
	void setUnselectedColor(video::SColor col);
	void setSelectedColor(video::SColor col);
	void setDisabledColor(video::SColor col);
	void setFont(IGUIFont* font);
	void setFontColor(video::SColor col);
	void setDrawBorder(bool draw);
	void setDraggable(bool draggable);
	void setDoubleClickTime(u32 time);

	//! texture used for thumbnail / slot mode
	void setTexture(video::ITexture* tex);
	video::ITexture* getTexture();

	// Action causing functions

	// start editing the text in the text box
	void startEditing();
	void finishEditing();

private:

	s32 getTextHeight();

	IGUIEditBox* TextBox;
	IGUIStaticText* StaticText;
	IGUIFont* Font;
	IGUISpriteBank* Sprites;
	core::rect<s32> iconRect;

	u32 lastClickTime, DoubleClickTime;

	EGUI_ICON_LAYOUT Layout;

	bool Selected, Animate, Editable;
	bool DrawBorder, Draggable;

	bool Dragging;
	core::position2di DragStart;

	s32 NormalSprite, PressedSprite;
	video::SColor UnselectedColor, SelectedColor, DisabledColor, FontColor;
	video::ITexture *Texture;
	bool Clip; // don't clip when dragging
};


} // namespace gui
} // namespace irr

#endif